﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Server.Models;
using Server.AdsService;
using System.Data;

namespace Server.AdsManage
{
    public class AdsBLL
    {
        AdsDAL aDal = new AdsDAL();
        public void AdsAdd(AdsManageModel ads)
        {
            try
            {
                aDal.AdsAdd(ads);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public void AdsEdit(AdsManageModel ads)
        {
            try
            {
                aDal.AdsEdit(ads);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public void AdsDel(int id)
        {
            try
            {
                aDal.AdsDel(id);
            }
            catch (Exception)
            {
                throw;
            }


        }
        public AdsManageModel[] GetAdsList()
        {
            try
            {
                DataTable dt = aDal.GetAdsList();
                AdsManageModel[] ads = new AdsManageModel[dt.Rows.Count];

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    var dr = dt.Rows[i];
                    ads[i] = new AdsManageModel()
                    {
                        id = Convert.ToInt32(dr["id"]),

                    };
                }
                return ads;
            
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}
